import { Injectable } from '@nestjs/common';
import { UserEntity } from '../entities/user.entity';
import { IsEmail, IsNotEmpty } from 'class-validator';
import { IsPassword } from '@/modules/core/dto/password-validate';
import { DtoValidation } from '@/modules/core/decorators/dto-validation.decorator';
import { IsPhoneNumber } from '@/modules/core/dto/phoneValidate';
import { IsUnique } from '@/modules/core/dto/uniqueValidate';

@Injectable()
@DtoValidation({ type: 'body' })
export class CreateUserDto {
  @IsUnique({ entity: UserEntity }, { message: '用戶名唯一' })
  @IsNotEmpty()
  username: string;

  @IsNotEmpty()
  @IsPassword(2, { message: '密码由数字大小写字母组成' })
  password: string;

  @IsUnique({ entity: UserEntity }, { message: '电话号码唯一' })
  @IsNotEmpty()
  @IsPhoneNumber()
  phone: string;

  @IsUnique({ entity: UserEntity }, { message: '邮箱唯一' })
  @IsEmail()
  @IsNotEmpty()
  email: string;
}
